package com.czk.utils;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/7/1 11:57
 */
public class JpaUtils {
    private static EntityManagerFactory factory;

    static {
        // 加载配置文件，常见entityManagerFactory
        factory = Persistence.createEntityManagerFactory("myJpa");
    }

    public static EntityManager getEntityManager() {
        return factory.createEntityManager();
    }
}
